<include file="Common/common" />
<?php $statusArr = array('0'=>'未激活','1'=>'已激活','2'=>'冻结'); ?>

<body>
	<div class="layui-tab-item layui-show">
		<div class="layui-main">
			<br>
			<form class="layui-form" action="{:U('/admin.php/User/user')}" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">搜索</label>
					<div class="layui-input-inline" id="div-nickname">
						<input type="text" placeholder="请输入用户账号" name="account" lay-verify="required"  class="layui-input" >
					</div>


					<div class="layui-input-inline">
						<button class="layui-btn" title="搜索" ><i class="layui-icon">&#xe615;</i></button>
					</div>
				</div>
			</form>
			<br>
			<div style="overflow-x: auto;">
				<table class="layui-table" >
					<thead>
							<tr>
								<th>编号</th>
								<th>用户账号</th>
								<th>真实姓名</th>
								<th>联系电话</th>
								<th>能量值/能量总汇</th>
								<th>任务/中心/交易积分</th>
								<th>动态/任务秘钥</th>
								<th>注册时间</th>
								<th>状态</th>
								<th>操作</th>
							</tr> 
						</thead>
						<tbody>
							<foreach name="userList" item="vo">
								<tr>
									<td>{$vo['id']}</td>
									<td>{$vo['account']}</td>
									<td>{$vo['truename']}</td>
									<td>{$vo['phone']}</td>
									<td>{$vo['top_num']}/{$vo['team_num']}</td>
									<td>{$vo['score_task']}/{$vo['score_center']}/{$vo['score_trading']}</td>
									<td>{$vo['key_dynamic']}/{$vo['key_task']}</td>
									<td><?php if(!empty($vo['createtime'])){echo date('Y-m-d H:i:s',$vo['createtime']); } ?></td>
									<td>
										<if condition="$vo['status'] eq 0 "><span style="color: orange;">{$statusArr[$vo['status']]}</span>
										<elseif condition="$vo['status'] eq 2"/><span style="color: red;">{$statusArr[$vo['status']]}</span>
										<else/><span>{$statusArr[$vo['status']]}</span>
										</if>
									</td>
									<td>
										<div class="layui-btn-group">
											<button class="layui-btn" onclick="func_collect(this,{$vo['id']})">收款方式</button>
											<if condition="$vo['status'] eq 1 ">
												<button class="layui-btn" onclick="func_lock(this,{$vo['id']})">冻结</button>
											<elseif condition="$vo['status'] eq 2 "/>
												<button class="layui-btn" onclick="func_unlock(this,{$vo['id']})">解封</button>
											</if>
										</div>
									</td>
								</tr>
							</foreach>
						</tbody>
				</table>
			</div>
			<div class="green-black">{$page}</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	function func_collect(obj,id){
		layer.open({
			type: 2,
			title: '收款方式',
			shadeClose: true,
			shade: 0.8,
			scrollbar: false,
			area: ['100%', '100%'],
			content: "/admin.php/User/collect?id="+id, //iframe的url
			
		});
	}

	//冻结账号
	function func_lock(obj,id){
		layer.confirm('确定冻结？',{offset:'none'},function(index){
			$.ajax({
	            type: "post",
	            url: "{:U('/admin.php/User/ctrl_lock')}",
	            data: {id:id},
	            dataType: "json",
	            success: function(rtJson){
	            	if (rtJson.code == 1) {
		               	setTimeout(function(){location.reload();}, 1000);
	               	}
	               	layer.msg(rtJson.msg);
	            }
	        });
		});
	}


	// 解封账号
	function func_unlock(obj,id){
		layer.confirm('确定解封？',{offset:'none'},function(index){
			$.ajax({
	            type: "post",
	            url: "{:U('/admin.php/User/ctrl_unlock')}",
	            data: {id:id},
	            dataType: "json",
	            success: function(rtJson){
	            	if (rtJson.code == 1) {
		               	setTimeout(function(){location.reload();}, 1000);
	               	}
	               	layer.msg(rtJson.msg);
	            }
	        });
		});
	}
</script>
<include file="Common/footer" />